maxbigras.com

Introduction

You can run your containers on Google Cloud Run without managing the underlying infrastructure (you don’t need to apply security patches to servers). Cloud Run is really fun and I just wish they supported GPUs (oh wow!).

Getting started with Cloud Run

To get started, build and deploy a Docker container.

  1. In a local directory, create a Dockerfile.

    FROM caddy
    ENTRYPOINT ["sh", "-c", "caddy respond --listen=0.0.0.0:${PORT:-8080} --body=\"hello world\n\""]
  2. Build your image.

    gcloud builds submit --project=$PROJECT --tag=gcr.io/$PROJECT/hello-world
  3. Deploy your container.

    gcloud run deploy hello-world --image=gcr.io/$PROJECT/hello-world --region=us-west1 --no-allow-unauthenticated

    Note: gcloud will print your app URL.

  4. Reach your running container; for example:

    $ curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" https://hello-world-231362033799.us-west1.run.app
    hello world

Discussion

You can quickly deploy your containers to Cloud Run without managing the underlying servers. The only limiting factor is you can’t run GPU workloads (oh wow!).

meta: build steps:

pandoc -f markdown -t html5 -o "2025-02-10 Cloud Run.html" "2025-02-10 Cloud Run.md"
# edit CSS to make code blocks wrap
scp "2025-02-10 Cloud Run.html" maxbigras.com:blog